# coding=utf-8

'''
识别网站开发语言，存在误报

ASP.NET
Server:Microsoft-IIS/6.0
Server:Microsoft-IIS/7.5
'''
import requests
import re
from mv import Smmulv
class CmsSb(object):

	def __init__(self):
		self.__mu =Smmulv()

	def Cx(self,line,url):

		#print url.headers
		strwz = str(url.headers)
		print strwz
		wz = re.findall(r"(PHP|ASP.NET|WAF|Servlet|yunjiasu-nginx|Apache-Coyote/1.1|zhuji.360.cn|JBoss|yunsuo_session_verify)",strwz,re.I)
		flag =True
		while flag:
			if ('yunjiasu-nginx' or 'WAF' or 'zhuji.360.cn' or 'yunsuo_session_verify') in wz:
				#flag =False #判断是否存在waf指纹

				continue
			else:#不存在扫描则扫描所有字典
				self.__mu.Sm(line=line,dic='dict/all.txt')
			if 'PHP' in wz:
				print 'PHP'
				self.__mu.Sm(line=line,dic='dict/php.txt')
				#flag =False
			if 'ASP.NET' in wz:
				print 'ASP!!!'
				self.__mu.Sm(line=line,dic='dict/asp.txt')
				#flag=False
			if ('Servlet' and 'JBoss') in wz:
				print 'jboss'
				self.__mu.Sm(line=line,dic='dict/jsp.txt')
				#flag=False
			if 'Apache-Coyote/1.1' in wz:
				print 'tomcat'

				flag=False
			if flag ==True:
				flag =False


# try:
# 	url = requests.get(url='http://qysso.csair.com/',allow_redirects=False,verify=False,timeout=10)
# except Exception,e:
# 	print e
#
# cms = CmsSb()
# cms.Cx(line='http://qysso.csair.com/',url=url)